<?php
    /**
     *	Text class
     *	Allows creation of a customised text string, containing a mixture of plain text and DataSet column
     *	values. Must be used in conjunction with a Component with a DataSet containing any given column names.
     *	@author	Simon Copsey <simon.copsey@gmail.com>
     *	@version 0.1
     *	@package framework
     */
    class Text {
        /**
	 * Metadata representation of plain text item.
	 * @global String $METADATA_PLAINTEXT
	 */ 
        public static $METADATA_PLAINTEXT = "plaintext";
	/**
	 * Metadata representation of DataSet column value item.
	 * @global String $METADATA_COLUMNVALUE
	 */ 
        public static $METADATA_COLUMNVALUE = "columnvalue";
        
        private $text =  array();
        private $metadata = array();
        
        /**
        * Add a plain text String to the text string.
        *
        * @param String $aString plain text string
        * @access public
        */
	public function addString($aString) {
            array_push($this->text, $aString);
            array_push($this->metadata, self::$METADATA_PLAINTEXT);
            return $this;
	}
	
        /**
        * Add a value from a given DataSet column to the text string.
        *
        * @param String $aColumnName name of column in DataSet
        * @access public
        */
	public function addColumnValue($aColumnName) {
            array_push($this->text, $aColumnName);
            array_push($this->metadata, self::$METADATA_COLUMNVALUE);
            return $this;
	}
        
        /**
        * Returns aggregated text.
        *
        * @return String aggregated text.
        * @access public
        */
        public function getText() {
            return $this->text;
        }
        
        /**
        * Returns aggregated text metadata.
        *
        * @return String aggregated text metadata.
        * @access public
        */
        public function getMetadata() {
            return $this->metadata;
        }
    }
?>